package ssm.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ssm.dao.IPermissionDao;
import ssm.domain.Permission;
import ssm.service.IPermissionService;

import java.util.List;

@Service
public class PermissionServiceImpl implements IPermissionService {

    @Autowired
    private IPermissionDao permissionDao;

    @Override
    public List<Permission> findAll() throws Exception {

        List<Permission> list = permissionDao.findAll();
        return list;
    }

    @Override
    public void save(Permission permission) {
        permissionDao.save(permission);
    }

    @Override
    public Permission findById(String id) throws Exception{
        return permissionDao.findById(id);
    }

    @Override
    public void deleteById(String id) throws Exception {
        /*对于存在中间表的删除，应该先删除中间表；然后删除该内容*/
        permissionDao.deleteFromRole_Permission(id);
        permissionDao.deleteById(id);
    }
}
